<?php
/** 
 * 类名：数据模型生成工具
 * 功能：完成数据模型生成
 * $Id: Tools.php 161 2009-07-22 01:15:01Z meetcd $
 */ 
 
class tools extends controller
{
  function index()
  {
	$tool = sf::getModel(config::get('database.engine','mysql'));
	$result = $tables =array();
	if($_POST['tables']){
		for($i=0,$n=count($_POST['tables']);$i<$n;$i++)
		{
		  $this->createmodel($_POST['tables'][$i]);
		  $result[] = $_POST['tables'][$i];
		}
	}
	view::set("title","Tools::Select tables!");
	view::set("tables",$tool->showTables());
	view::set("result",$result);
	view::display("tools");
  }
  
  function createmodel($table)
  {
    $tool = sf::getModel(config::get('database.engine','mysql'));
	$fields = $tool->showFields($table);
    $tools = sf::getLib("tools_model",$table,$fields);
    $tools->generate();
  }
  
}

?>